home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / File::Basename.Z / File::Basename
Encoding:
Text File  |  1998-10-28  |  6.8 KB  |  199 lines

  1.  
  2.  
  3.  
  4.      FFFFiiiilllleeee::::::::BBBBaaaasssseeeennnnaaaammmmeeee((((3333))))22223333////JJJJuuuullll////99998888    ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))FFFFiiiilllleeee::::::::BBBBaaaasssseeeennnnaaaammmmeeee((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       fileparse - split a pathname into pieces
  10.  
  11.       basename - extract just the filename from a path
  12.  
  13.       dirname - extract just the directory from a path
  14.  
  15.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  16.           use File::Basename;
  17.  
  18.           ($name,$path,$suffix) = fileparse($fullname,@suffixlist)
  19.           fileparse_set_fstype($os_string);
  20.           $basename    = basename($fullname,@suffixlist);
  21.           $dirname = dirname($fullname);
  22.  
  23.           ($name,$path,$suffix) = fileparse("lib/File/Basename.pm","\.pm");
  24.           fileparse_set_fstype("VMS");
  25.           $basename    = basename("lib/File/Basename.pm",".pm");
  26.           $dirname = dirname("lib/File/Basename.pm");
  27.  
  28.  
  29.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  30.       These    routines allow you to parse file specifications    into
  31.       useful pieces    using the syntax of different operating
  32.       systems.
  33.  
  34.       fileparse_set_fstype
  35.           You select the syntax via    the routine
  36.           _f_i_l_e_p_a_r_s_e__s_e_t__f_s_t_y_p_e().
  37.  
  38.           If the argument passed to    it contains one    of the
  39.           substrings "VMS",    "MSDOS", "MacOS", "AmigaOS" or
  40.           "MSWin32", the file specification    syntax of that
  41.           operating    system is used in future calls to _f_i_l_e_p_a_r_s_e(),
  42.           _b_a_s_e_n_a_m_e(), and _d_i_r_n_a_m_e().  If it    contains none of these
  43.           substrings, UNIX syntax is used.    This pattern matching
  44.           is case-insensitive.  If you've selected VMS syntax, and
  45.           the file specification you pass to one of    these routines
  46.           contains a "/", they assume you are using    UNIX emulation
  47.           and apply    the UNIX syntax    rules instead, for that
  48.           function call only.
  49.  
  50.           If the argument passed to    it contains one    of the
  51.           substrings "VMS",    "MSDOS", "MacOS", "AmigaOS", "os2",
  52.           "MSWin32"    or "RISCOS", then the pattern matching for
  53.           suffix removal is    performed without regard for case,
  54.           since those systems are not case-sensitive when opening
  55.           existing files (though some of them preserve case    on
  56.           file creation).
  57.  
  58.           If you haven't called _f_i_l_e_p_a_r_s_e__s_e_t__f_s_t_y_p_e(), the    syntax
  59.           is chosen    by examining the builtin variable $^O
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      FFFFiiiilllleeee::::::::BBBBaaaasssseeeennnnaaaammmmeeee((((3333))))22223333////JJJJuuuullll////99998888    ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))FFFFiiiilllleeee::::::::BBBBaaaasssseeeennnnaaaammmmeeee((((3333))))
  71.  
  72.  
  73.  
  74.           according    to these rules.
  75.  
  76.       fileparse
  77.           The _f_i_l_e_p_a_r_s_e() routine divides a    file specification
  78.           into three parts:    a leading ppppaaaatttthhhh,    a file nnnnaaaammmmeeee, and a
  79.           ssssuuuuffffffffiiiixxxx.  The ppppaaaatttthhhh    contains everything up to and
  80.           including    the last directory separator in    the input file
  81.           specification.  The remainder of the input file
  82.           specification is then divided into nnnnaaaammmmeeee and ssssuuuuffffffffiiiixxxx based
  83.           on the optional patterns you specify in @suffixlist.
  84.           Each element of this list    is interpreted as a regular
  85.           expression, and is matched against the end of nnnnaaaammmmeeee.  If
  86.           this succeeds, the matching portion of nnnnaaaammmmeeee is removed
  87.           and prepended to ssssuuuuffffffffiiiixxxx.    By proper use of @suffixlist,
  88.           you can remove file types    or versions for    examination.
  89.  
  90.           You are guaranteed that if you concatenate ppppaaaatttthhhh, nnnnaaaammmmeeee,
  91.           and ssssuuuuffffffffiiiixxxx together in that order, the result will
  92.           denote the same file as the input    file specification.
  93.  
  94.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  95.       Using    UNIX file syntax:
  96.  
  97.           ($base,$path,$type) = fileparse('/virgil/aeneid/draft.book7',
  98.                           '\.book\d+');
  99.  
  100.       would    yield
  101.  
  102.           $base eq 'draft'
  103.           $path eq '/virgil/aeneid/',
  104.           $type eq '.book7'
  105.  
  106.       Similarly, using VMS syntax:
  107.  
  108.           ($name,$dir,$type) = fileparse('Doc_Root:[Help]Rhetoric.Rnh',
  109.                          '\..*');
  110.  
  111.       would    yield
  112.  
  113.           $name eq 'Rhetoric'
  114.           $dir  eq 'Doc_Root:[Help]'
  115.           $type eq '.Rnh'
  116.  
  117.  
  118.       basename
  119.            The _b_a_s_e_n_a_m_e() routine returns the first    element    of the
  120.            list produced by    calling    _f_i_l_e_p_a_r_s_e() with the same
  121.            arguments, except that it always    quotes metacharacters
  122.            in the given suffixes.  It is provided for programmer
  123.            compatibility with the UNIX shell command _b_a_s_e_n_a_m_e(1).
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      FFFFiiiilllleeee::::::::BBBBaaaasssseeeennnnaaaammmmeeee((((3333))))22223333////JJJJuuuullll////99998888    ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))FFFFiiiilllleeee::::::::BBBBaaaasssseeeennnnaaaammmmeeee((((3333))))
  137.  
  138.  
  139.  
  140.       dirname
  141.            The _d_i_r_n_a_m_e() routine returns the directory portion of
  142.            the input file specification.  When using VMS or    MacOS
  143.            syntax, this is identical to the    second element of the
  144.            list produced by    calling    _f_i_l_e_p_a_r_s_e() with the same
  145.            input file specification.  (Under VMS, if there is no
  146.            directory information in    the input file specification,
  147.            then the    current    default    device and directory are
  148.            returned.)  When    using UNIX or MSDOS syntax, the    return
  149.            value conforms to the behavior of the UNIX shell
  150.            command _d_i_r_n_a_m_e(1).  This is usually the    same as    the
  151.            behavior    of _f_i_l_e_p_a_r_s_e(),    but differs in some cases.
  152.            For example, for    the input file specification _l_i_b/,
  153.            _f_i_l_e_p_a_r_s_e() considers the directory name    to be _l_i_b/,
  154.            while _d_i_r_n_a_m_e() considers the directory name to be .).
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.